/*
 * ManyTrees.h
 *
 *  Created on: Mar 22, 2012
 *      Author: pickrell
 */

#ifndef MANYTREES_H_
#define MANYTREES_H_
#include "TreeState.h"
#include <gsl/gsl_rng.h>
using namespace std;

class ManyTrees{
public:
	ManyTrees();
	ManyTrees(string, PhyloPop_params *);
	vector<TreeState> d;
	void print();
	void print_allcoaltimes();
	vector<double> get_all_coaltimes();

	vector<double> bpoints;
	vector<double> popsizes;

	double t, p1;
	vector<double> bpoints1;
	vector<double> bpoints2;
	vector<double> bpoints3;
	vector<double> popsizes1;
	vector<double> popsizes2;
	vector<double> popsizes3;


	void set_bpoints(int);
	void set_bpoints(vector<double>);
	void read_bpoints(string);
	void set_structured_bpoints_popsizes(int);
	void init_structure(int, gsl_rng*);
	void optimize_all_tips();
	void setp1();

	//bootstrap
	vector<vector<double> > bootstrap(int, gsl_rng*);
	int golden_section_popsize_bootstrap(vector<int>, int, double, double, double , double, int*);
	double llk_bootstrap(vector<int>);
	void optim_popsize_bootstrap(vector<int>, int);
	void optim_all_popsizes_bootstrap(vector<int>);
	void bootstrap_and_print(string, int, gsl_rng*);
	//

	void set_known(int);
	double epsilon;
	void print_bpoints();
	void init_popsizes();
	void print_popsizes();
	void print_state(string);
	void print_struct_state(string);
	void print_all_trees(string);

	double llk();
	double llk_structured();
	double llk_structured_no3();
	double llk_structured_no3(int);
	int golden_section_struct_popsize(int, int, double, double, double , double, int*);
	int golden_section_popsize(int, double, double, double , double, int*);
	void optim_popsize(int);
	void optim_struct_popsize(int, int);
	void optim_all_popsizes();
	void optim_all_struct_popsizes();
	void optim_all_struct();
	void iterate_optim_all_struct();
	double phi, resphi;
};


#endif /* MANYTREES_H_ */
